<?php
/**
*管理后台
**/
namespace Fang\AlysmsBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; //配置route
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Fang\AlysmsBundle\Event\AlySmsTypeEvent;
use Fang\AlysmsBundle\Entity\SmsType;

class ManageController extends Controller
{
	/**
	*@Route("/alysms/list", name="alysms_manage_index")
	**/
	public function indexAction()
	{
		$dispatcher = new EventDispatcher();
		$dispatcher->addListener(AlySmsTypeEvent::NAME, function (Event $event) {
    // will be executed when the foo.action event is dispatched
    // （此处的代码）将在foo.action事件被派遣之后执行
			$smsType = new SmsType;
			$smsType->setSmstype("test");
			$smsType->setLabel("ces");
			$smsType->setDescription("just for test");
			echo "ok";
			$event->setType($smsType);
});
		var_dump(\Fang\AlysmsBundle\FangAlysmsBundle::getSmsTypes());
		return new Response("just test");
	}
}